﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.SM
{
    /// <summary>
    /// 生命附加家庭收入保障定期寿险
    /// </summary>
    class Class9
    {
        /// <summary>
        /// 身故保险金给付
        /// （投保人)
        /// </summary>
        /// <param name="ppa"></param>
        /// <param name="da"></param>
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period>0 && ppa.SchemePeriodActing.SchemeActing.PeriodActings.FirstOrDefault(p=>p.HolderStates.Contains("身故") && p.Period<=ppa.Period)!=null )
            {
                da.Value = ppa.Amount;
            }
        }
        /// <summary>
        /// 全残保险金给付
        /// </summary>
        /// <param name="ppa"></param>
        /// <param name="da"></param>
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0 && ppa.SchemePeriodActing.SchemeActing.PeriodActings.FirstOrDefault(p => p.HolderStates.Contains("全残") && p.Period <= ppa.Period) != null)
            {
                da.Value = ppa.Amount;
            }
        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if( ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                    
                }
                else if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.05;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病全残"))
            {
                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                }
                else if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.05;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.SchemePeriodActing.InsurantStates.Add("全残");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.05;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.SchemePeriodActing.InsurantStates.Add("身故");
                ppa.IsCurrentFinish = true;
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("意外全残"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee * 1.05;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.SchemePeriodActing.InsurantStates.Add("全残");
                ppa.IsCurrentFinish = true;
            }

        }

    }
}
